Option Infer On
Imports System.IO
Imports System.Net
Namespace Base
    Public Class NetRequest
        Public Function ReturnWebResponse() As WebResponse
            Return Nothing
        End Function
        Public Function GetFromWeb(ByVal url As Uri, ByVal requireCreds As Boolean, Optional ByVal username As String = "", Optional ByVal password As String = "") As IO.Stream
            ''TODO: Add ETag/If-Modified-Since support
            ''TODO: Make more generic
            Dim webRequ As WebRequest = WebRequest.Create(url)
            Dim httpReq As HttpWebRequest = TryCast(webRequ, HttpWebRequest)
            If Not webRequ Is Nothing Then
                httpReq.Timeout = 1 * 60 * 1000
                httpReq.UserAgent = "FM/ThreeDotOh (http://www.codeplex.com/feedmonster)"
                httpReq.Method = "GET"
            End If
            Dim resp As HttpWebResponse = TryCast(webRequ.GetResponse, HttpWebResponse)
            Return resp.GetResponseStream
        End Function
        Private Function DataStream(ByVal Stream As IO.Stream) As String
            Dim text3 As String = ""
            Dim Stream1 As Stream = Stream
            Dim reader1 As New StreamReader(Stream1, True)
            text3 = reader1.ReadToEnd
            Stream1.Close()
            reader1.Close()
            My.Computer.FileSystem.WriteAllText(Microsoft.VisualBasic.Compatibility.VB6.GetPath() & "cache", text3, False)
            Return Microsoft.VisualBasic.Compatibility.VB6.GetPath() & "cache"
        End Function
    End Class
End Namespace
